home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / thesource6.dms / thesource6.adf / Source / Compression / hcompress.lha / hcompress / vms / hcompress.com < prev    next >
Encoding:
Text File  |  1992-04-24  |  3.7 KB  |  133 lines

  1. $! hcompress.com
  2. $!
  3. $! VMS command file to do H-transform image compression for a list of image
  4. $! files in .hhh, .hhd format.  *.hhd files are replaced by *.hhd_H.
  5. $!
  6. $! Program will compress only I*2 images with no group parameters.
  7. $! (A warning is issued for other images.)
  8. $!
  9. $! The default compression scale factor is 666, which is appropriate for
  10. $! gasp images (gives about a factor of 10 compression, negligible loss in
  11. $! information.)
  12. $!
  13. $! R. White, 20 April 1992
  14. $!
  15. $! determine where this procedure lives (assume that the executable files
  16. $! are in this same directory)
  17. $!
  18. $ shellfile=f$parse(f$environment("procedure"),,,,"NO_CONCEAL")-"]["
  19. $ cdir=f$extract(0,f$locate("]",shellfile),shellfile) + "]"
  20. $ prgnam=f$parse(shellfile,,,"NAME")
  21. $!
  22. $ echo:=write sys$output
  23. $ hc:=$'cdir'hcomp
  24. $!
  25. $ if p1.eqs.""
  26. $ then
  27. $    echo "Usage: ",prgnam," [options] files... [options] files..."
  28. $    echo "  where options are:"
  29. $    echo "     -s scale to specify the compression scale factor"
  30. $    echo "     -k       to keep the uncompressed file (default)"
  31. $    echo "     -r       to remove the uncompressed file"
  32. $    echo ""
  33. $    echo "Default compression scale factor is 666 (good for GASP images.)"
  34. $    echo "Specify .hhd extension on files.  Compressed files are named *.*_H."
  35. $    exit
  36. $ endif
  37. $!
  38. $ scale=666
  39. $ nextscale=0
  40. $ remove=0
  41. $ p=1
  42. $ ploop:
  43. $   parm = p'p
  44. $   if parm.eqs."" then exit                ! all done
  45. $   if nextscale.eq.1
  46. $   then
  47. $      scale=parm                    ! set scale
  48. $      nextscale=0
  49. $      echo "Using scale ", scale
  50. $      goto endploop
  51. $   endif
  52. $   if parm.eqs."-S"
  53. $   then
  54. $      nextscale=1                    ! next parm is scale
  55. $      goto endploop
  56. $   endif
  57. $   if parm.eqs."-R"
  58. $   then
  59. $      remove=1                        ! remove original files
  60. $      goto endploop
  61. $   endif
  62. $   if parm.eqs."-K"
  63. $   then
  64. $      remove=0                        ! keep original files
  65. $      goto endploop
  66. $   endif
  67. $!
  68. $! compress the file(s) specified by this parameter
  69. $! use f$search to allow the use of wildcards in file specifications
  70. $!
  71. $   datafile=f$search(parm,1)                ! get original file name
  72. $   if datafile.eqs.""
  73. $   then
  74. $      echo prgnam,": ",datafile,": No such file"
  75. $      goto endploop
  76. $   endif
  77. $!
  78. $! save name of first file to correct the stupid behavior of f$search
  79. $! when the file argument does not contain a wildcard character
  80. $!
  81. $   firstfile=datafile
  82. $ floop:
  83. $      dext=f$parse(datafile,,,"TYPE")
  84. $      hext=f$extract(0,3,dext)+"H"
  85. $      headfile=f$parse(hext+";",datafile,,,"SYNTAX_ONLY")    ! header name
  86. $      cext=dext+"_H"
  87. $      compfile=f$parse(cext+";",datafile,,,"SYNTAX_ONLY")    ! compress name
  88. $!
  89. $! check that header file exists
  90. $! if compressed file already exists, we'll rely on VMS to create a new version
  91. $!
  92. $      if f$extract(3,1,dext).nes."D"
  93. $      then
  94. $         echo prgnam,": ",datafile," does not have .xxd extension"
  95. $         goto endfloop
  96. $      endif
  97. $      if f$search(headfile,2).eqs.""
  98. $      then
  99. $         echo prgnam,": ",headfile,": No such file"
  100. $         goto endfloop
  101. $      endif
  102. $!
  103. $! perform compression
  104. $!
  105. $      echo datafile
  106. $      define/user sys$output 'compfile'
  107. $      hc -v -s 'scale' -i hhh 'datafile' 'headfile'
  108. $      if $status.eq.1                ! check for success
  109. $      then
  110. $         if remove.eq.1 then delete 'datafile'    ! delete original file
  111. $      else
  112. $         echo prgnam,": ",datafile," not compressed: compression error"
  113. $         delete 'compfile'                ! delete compressed file
  114. $      endif
  115. $ endfloop:
  116. $!
  117. $! get next file name
  118. $!
  119. $! be careful: f$search returns the same name every time if there are
  120. $! no wildcard characters in the argument (dumb)
  121. $!
  122. $      datafile=f$search(parm,1)
  123. $      if datafile.nes.firstfile
  124. $      then
  125. $         if datafile.nes."" then goto floop
  126. $      endif
  127. $!
  128. $! go to next parameter
  129. $!
  130. $ endploop:
  131. $   p = p+1
  132. $   goto ploop
  133.